from base import Subject

class WeatherData(Subject):
    def __init__(self):
        super().__init__()
        self._temperature: float = 0
        self._humidity: float = 0
        self._pressure: float = 0

    def notify_observers(self):
        if self._changed:
            for i in self._observers:
                i.update(self._temperature, self._humidity, self._pressure)
        self._changed = False

    def measurements_changed(self):
        self.set_change()
        self.notify_observers()

    def set_measurements(self, temperature, humidity, pressure):
        self._temperature = temperature
        self._humidity = humidity
        self._pressure = pressure
        self.measurements_changed()

    def get_temperature(self) -> float:
        return self._temperature

    def get_humidity(self) -> float:
        return self._humidity

    def get_pressure(self) -> float:
        return self._pressure
